package at.ac.univie.zsu.aguataplan.video.util;

import org.apache.log4j.Logger;

import at.ac.univie.zsu.aguataplan.exception.FileHandlingException;
import at.ac.univie.zsu.aguataplan.util.Constants;
import at.ac.univie.zsu.aguataplan.video.IVideoService;

/**
 * @author gerry
 * 
 */
public class ThreadLocal extends ThreadWorking implements Constants {
	private static Logger log = Logger.getLogger(ThreadLocal.class);

	private IVideoService iVideoService;

	private FileHandling fileHandling;

	// ----------------------------------------------------
	// CONSTRUCTOR
	// ----------------------------------------------------

	public ThreadLocal(IVideoService iVideoService, String dirInput,
			String fileInput, String dirOutput, String fileOutput) {
		super(dirInput, fileInput, dirOutput, fileOutput);

		this.iVideoService = iVideoService;

		fileHandling = new FileHandling(iVideoService);

	}

	// ----------------------------------------------------
	// METHODS
	// ----------------------------------------------------

	public void run() {

		try {
			fileHandling.cpFile(dirInput, fileInput, dirOutput, fileOutput);
		} catch (FileHandlingException e) {
			log.error(e.toString());
			this.retValue = e.getStatus();
		}

	}

	public int delFile() {
		this.retValue = RET_OK;
		try {
			fileHandling.delFile(dirOutput, fileOutput);
		} catch (FileHandlingException e) {
			log.error(e.toString());
			this.retValue = e.getStatus();
		}
		return this.retValue;
	}

}
